package com.itheima.课件.charstream.mycharstream;

import java.io.*;

/*
    练习: 文件转码
        需求;将a.txt中的内容读取到内存，并且以GBK形式编码到c.txt中保存
 */
public class Test02 {
    public static void main(String[] args) throws IOException {
        //1. 创建字符输入流【转换流】 ,指定解码规则为"UTF-8"
        InputStreamReader isr = new InputStreamReader(new FileInputStream("day13_字符流&properties\\a.txt"),"UTF-8");
        //2. 创建字符输出流【转换流】,指定编码规则为"GBK"
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("day13_字符流&properties\\c.txt"),"GBK");

        char[] chs = new char[1024];
        int len;

        while ((len = isr.read(chs))!= -1){
            osw.write(chs,0,len);
        }

        osw.close();
        isr.close();
    }
}
